package com.autumn.zero.authorization.configure;

import java.util.Map;

import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;

import com.autumn.security.configure.IAutumnPermissionFilter;
import com.autumn.zero.authorization.services.IResourcesService;

/**
 * 权限过滤
 * 
 * @author 杨昌国 2018-12-12 12:36:59
 */
public class ZeroAutumnPermissionFilter implements IAutumnPermissionFilter {

	@Autowired
	private IResourcesService resourcesService;

	@Override
	public void initFilter(ShiroFilterFactoryBean factoryBean, SecurityManager securityManager) {
		// 权限控制map.
		Map<String, String> filterMap = resourcesService.shiroPermissionFilterMap();
		filterMap.put("/**", "anon");
		factoryBean.setFilterChainDefinitionMap(filterMap);
		factoryBean.setUnauthorizedUrl("/api/error");
	}

	@Override
	public void resetPermission() {

	}

}
